package com.twentytwok.hospitalsystem22K.mapper;

import com.twentytwok.hospitalsystem22K.common.PieBo;
import com.twentytwok.hospitalsystem22K.pojo.Drug;
import com.twentytwok.hospitalsystem22K.pojo.DrugExample;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface DrugMapper {
    long countByExample(DrugExample example);

    int deleteByExample(DrugExample example);

    int deleteByPrimaryKey(Integer id);

    int insert(Drug record);

    int insertSelective(Drug record);

    List<Drug> selectByExample(DrugExample example);

    Drug selectByPrimaryKey(Integer id);

    int updateByExampleSelective(@Param("record") Drug record, @Param("example") DrugExample example);

    int updateByExample(@Param("record") Drug record, @Param("example") DrugExample example);

    int updateByPrimaryKeySelective(Drug record);

    int updateByPrimaryKey(Drug record);

    List<Drug> selectByExampleMine(Map<String, Object> map);


    int insertDrug(Map<String, Object> map);

    int updateDrug(Map<String, Object> map);

    int deleteDrug(Integer id);

    @Select("SELECT count(*) AS value , name\n" +
            "    FROM\n" +
            "    (select case when price > 0 and price < 50 then '0~50'\n" +
            "    when price >= 50 and price < 100 then '50~100'\n" +
            "    when price >= 100 and price < 200  then '100~200'\n" +
            "    when price >= 200 and price < 500 then '200~500'\n" +
            "    else 'over 500'\n" +
            "    end as name\n" +
            "    FROM drug\n" +
            "    WHERE 1\n" +
            "    ) AS  price_summaries\n" +
            "    GROUP BY name;")
    List<PieBo> pie();

}